import reportSaveWidths from './reportSaveWidths.js';
function nctableSaveWidth(pk_report){
    let self=this;
    let tableScrollThead = document.getElementsByClassName('u-table-scroll')[0];
    let scrollTh = tableScrollThead.querySelectorAll('thead.u-table-thead th');
    let scrollCol = tableScrollThead.querySelectorAll('div.u-table-header colgroup col');
    let tableLeftThead=document.getElementsByClassName('u-table-fixed-left')[0];
    let leftTh = tableLeftThead.querySelectorAll('thead.u-table-thead th');
    let leftCol = tableLeftThead.querySelectorAll('div.u-table-header colgroup col');
    let scrollWidthArr=[],leftWidthArr=[];
    //[{"colname":"unitName","colwidth":"147"}]
    for (let i = 0; i < scrollTh.length; i++) {
        let dataindex = scrollTh[i].getAttribute('data-col-key');//dataindex
        if (dataindex&&dataindex!='blankrow') {
            let scrollWidthObj = {};
            scrollWidthObj.colname=dataindex;
            scrollWidthObj.colwidth = scrollTh[i].getAttribute('data-th-width')||'1';//scrollCol[i].style.width.replace(/px/, '');//th[i].width;
            scrollWidthArr.push(scrollWidthObj);
        }
    }
    for (let ii = 0; ii < leftTh.length; ii++) {
        let attrcode = leftTh[ii].getAttribute('data-col-key');//dataindex
        if (attrcode&&attrcode!='blankrow') {
            let leftWidthObj = {};
            leftWidthObj.colname=attrcode;
            leftWidthObj.colwidth= leftTh[ii].getAttribute('data-th-width')||'1';//th[i].width;
            leftWidthArr.push(leftWidthObj);
        }
    }
    let widthArr=scrollWidthArr.concat(leftWidthArr);
    reportSaveWidths(pk_report, widthArr, self.state.json);
}
export{nctableSaveWidth}